using System;
using System.Collections.Generic;
using System.Windows.Browser;

namespace HtmlUtilities.UITest
{
    public static class WindowCommands
    {
        public static IEnumerable<Command<string>> GetCommands()
        {
            return new List<Command<string>>
                       {
                           new Command<string>("Alert", () => { Html.Page.Window.Alert("Alert"); return "Alert Sent"; }),
                           new Command<string>("Confirm", () => Html.Page.Window.Confirm("Confirm").ToString()),
                           new Command<string>("Prompt", () => Html.Page.Window.Prompt("Prompt")),
                           new Command<string>("CreateInstance", CreateInstance),
                           new Command<string>("NavigateToBookmark", () => { Html.Page.Window.NavigateToBookmark("#BM"); return "Navigated to #BM"; }),
                           new Command<string>("CurrentBookmark", () => Html.Page.Window.CurrentBookmark),
                           new Command<string>("Eval", () => Html.Page.Window.Eval("1 + 2").ToString()),
                           new Command<string>("Navigate", () => { Html.Page.Window.Navigate(new Uri("http://www.cnn.com/")); return "Navigate to CNN";}),
                           new Command<string>("NavigateNew", () => { Html.Page.Window.Navigate(new Uri("http://www.cnn.com/"), "_blank"); return "Navigate to CNN";}),
                           new Command<string>("NavigateOptions", () => { Html.Page.Window.Navigate(new Uri("http://www.cnn.com/"), "_blank", "height=200,width=400"); return "Navigate to CNN";}),
                       };
        }

        private static string CreateInstance()
        {
            var result = Html.Page.Window.CreateInstance("MyNameIs", "Brian");
            return result.GetProperty("Name") as string;
        }
    }
}